
varying float vIntensity;
varying vec2 vUv;

uniform float uStrength;
uniform float uThickness;

void main(){
    //传递uv到片元着色器
    vUv = uv;
    //将normal数据和模型矩阵相乘得到实际的方向矩阵
    vec3 worldNormal = normalize(modelMatrix * vec4( normal, 0.0)).xyz;
    //将position数据和模型矩阵相乘得到实际的模型点位置
    vec3 modelPosition = (modelMatrix * vec4(position, 1.0)).xyz;
    //uCenter(中心点)到相机点的单位向量
    vec3 dirToCamera = normalize(cameraPosition - modelPosition);
    //将两个相连点乘得到乘积，乘积为0，证明两个向量垂直，此时让强度为1
    vIntensity = 1.0 - dot(worldNormal, dirToCamera);

    vIntensity = pow(vIntensity * uThickness, uStrength);

    gl_Position = projectionMatrix * modelViewMatrix * vec4( position , 1.0);
}